const child_process = require("child_process");

const Course = function(gui, cmd) {
    this.gui = gui;
    this.cmd = cmd + "";
    this.init();
};

Course.prototype = {
    init() {
        this.run(this.cmd);
    },

    run: function(command) {
        //var self = this;
        this.worker = child_process.exec(command, {
            //10M
            maxBuffer: 10 * 1024 * 1024
        });

        //stdout可读流，用来接收数据库
        this.worker.stdout.on("data", (data) => {
            console.log(data.toString());
            //self.sendMessage(data.toString());
        });

        //this.worker.stderr.on("data", function(data) {
        //    self.sendMessage(data.toString());
        //});

        //this.worker.on("close", function(code) {
        //    self.closeForFinish(code);
        //});

        return this;
    },
};
module.exports = Course;